package com.beidouapp.esb.intercepter;

import java.util.Locale;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.ext.ExceptionMapper;

import com.beidouapp.esb.pojo.CommonResponse;

public class InvokeFaultExceptionMapper implements ExceptionMapper
{
	public Response toResponse(Throwable ex)
	{
		CommonResponse response = new CommonResponse();
		response.setErrorcode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
		response.setMessage(ex.getMessage());
		ResponseBuilder rb = Response.status(Response.Status.INTERNAL_SERVER_ERROR);
		rb.type("application/json;charset=UTF-8");
		rb.entity(response);
		rb.language(Locale.SIMPLIFIED_CHINESE);
		Response r = rb.build(); 
		return r;
	}

}
